#ifndef BUSINESSGROUP_H
#define BUSINESSGROUP_H
#include <string>
#include <memory>
#include <protocol/protocol.h>
#include <hv/Channel.h>
#include <map>

class BusinessGroup
{
public:

    // 删除拷贝构造函数和拷贝赋值操作符
    BusinessGroup(BusinessGroup const&) = delete;
    BusinessGroup& operator=(BusinessGroup const&) = delete;
    // 提供一个全局唯一的接口
    static BusinessGroup& getInstance() {
        static BusinessGroup instance;
        return instance;
    }

    // check group if exist
    bool checkGroup(const std::string& groupName);
    // receive a request for create a group

    void recvCreateGroupRequest(std::shared_ptr<Protocol> protocol, const hv::SocketChannelPtr& channel);

    // update group list
    void recvUpdateGroupList(std::shared_ptr<Protocol> protocol, const hv::SocketChannelPtr& channel);
    void updateGroupList(const std::string& account, const hv::SocketChannelPtr& channel);

    // receive a request to join a group

    void recvJoinGroupRequest(std::shared_ptr<Protocol> protocol, const hv::SocketChannelPtr& channel);

    //
    uint64_t getGroupID(const std::string& groupName);

    // receive a group message
    void recvGroupMessage(std::shared_ptr<Protocol> protocol, const hv::SocketChannelPtr& channel);

    // leave a group
    void recvLeaveGroup(std::shared_ptr<Protocol> protocol, const hv::SocketChannelPtr& channel);

    // receive reply of group request
    void recvReplyOfGroupApply(std::shared_ptr<Protocol> protocol, const hv::SocketChannelPtr& channel);
    // update group list
    void recvUpdateGroupRequestList(std::shared_ptr<Protocol> protocol, const hv::SocketChannelPtr& channel);
    void updateGroupRequestList(const std::string& account, const hv::SocketChannelPtr& channel);

    // message Send time;


private:
    std::map<std::string, uint64_t> groupInfoStore;



    BusinessGroup();
};

#endif // BUSINESSGROUP_H
